import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
import Layout from '../views/layout/Layout'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)


/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/cmn',
    component: Layout,
    redirect: '/cmn/list',
    name: '数据管理',
    alwaysShow: true,
    meta: { title: '数据管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '数据字典',
        component: () => import('@/views/dict/list'),
        meta: { title: '数据字典', icon: 'table' }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/userInfo/list',
    name: 'userInfo',
    meta: { title: '用户管理', icon: 'table' },
    alwaysShow: true,
    children: [
      {
        path: 'userInfo/list',
        name: '用户列表',
        component: () => import('@/views/user/userInfo/list'),
        meta: { title: '用户列表', icon: 'table' }
      },
      {
        path: 'userInfo/show/:id',
        name: '用户查看',
        component: () => import('@/views/user/userInfo/show'),
        meta: { title: '用户查看' },
        hidden: true
      },
      {
        path: 'userInfo/authList',
        name: '认证审批列表',
        component: () => import('@/views/user/userInfo/authList'),
        meta: { title: '认证审批列表', icon: 'table' }
      },
    ]
  },
  {
    path: '/dashboard',
    component: Layout,
    redirect: '/dashboard',
    name: '仓库管理',
    meta: { title: '仓库管理', icon: 'table' },
    alwaysShow: true,
    children: [
      {
        path: '/StockInManager',
        name: '入库管理',
        component: () => import('@/views/warehouse/StockInManager/index'),
        meta: { title: '入库管理', icon: 'table', affix: false }
      },
      {
        path: '/addStockIn',
        name: '新增入库单',
        component: () => import('@/views/warehouse/StockInManager/addStockIn'),
        meta: { title: '新增入库单', icon: 'table', affix: false },
        hidden: true
      },
      {
        path: '/StockInDetail/:ioOrderNo',
        name: '入库单详情',
        component: () => import('@/views/warehouse/StockInManager/StockInDetail'),
        meta: { title: '入库单详情', icon: 'table', affix: false },
        hidden: true
      },
      {
        path: '/StockOutManager',
        name: '出库管理',
        component: () => import('@/views/warehouse/StockOutManager/index'),
        meta: { title: '出库管理', icon: 'table', affix: false }

      },
      {
        path: '/addStockOut',
        name: '新增出库单',
        component: () => import('@/views/warehouse/StockOutManager/addStockOut'),
        meta: { title: '新增出库单', icon: 'table', affix: false },
        hidden: true
      },

      {
        path: '/StockOutDetail/:ioOrderNo',
        name: '出库单详情',
        component: () => import('@/views/warehouse/StockOutManager/StockOutDetail'),
        meta: { title: '出库单详情', icon: 'table', affix: false },
        hidden: true
      },

      {
        path: '/warehouseManager',
        name: '库存管理',
        component: () => import('@/views/warehouse/warehouseManager/index'),
        meta: { title: '库存管理', icon: 'table', affix: false }

      },
      {
        path: '/warehouseDetail',
        name: '库存详情',
        component: () => import('@/views/warehouse/warehouseManager/warehouseDetail'),
        meta: { title: '库存详情', icon: 'table', affix: false },
        hidden: true
      }
    ]
  },
  {
    path: '/purchaseManager',
    component: Layout,
    redirect: '/purchaseManager',
    name: '采购管理',
    meta: { title: '采购管理', icon: 'table' },
    alwaysShow: true,
    children: [
      {
        path: '/need',
        name: 'need',
        component: () => import('@/views/purchaseManager/need'),
        meta: { title: '需求单', icon: 'table', affix: false }
      },
      {
        path: '/DemandAllocation',
        name: 'DemandAllocation',
        component: () => import('@/views/purchaseManager/DemandAllocation'),
        meta: { title: '需求分配', icon: 'table' }
      },
      {
        path: '/purchase',
        name: 'purchase',
        component: () => import('@/views/purchaseManager/purchase'),
        meta: { title: '采购单', icon: 'table' }
      },
      {
        path: '/newNeed',
        name: 'newNeed',
        component: () => import('@/views/purchaseManager/newNeed'),
        meta: { title: '新增需求单', icon: 'table', noCache: false },
        hidden: true
      },
      {
        path: '/distributionDemandOrderDetaisl/:id',
        name: 'DemandOrderDetails',
        component: () => import('@/views/purchaseManager/DistributionDemandOrder/operationDemandSheet'),
        meta: { title: '分配需求单详情', icon: 'dashboard', noCache: false },
        hidden: true
      },
      {
        path: '/editDemandList',
        name: 'DemandOrderDetails',
        component: () => import('@/views/purchaseManager/editDemandList'),
        meta: { title: '需求单编辑', icon: 'dashboard', noCache: false },
        hidden: true
      },
      {
        path: '/purchaseOrderDetails',
        name: 'purchaseOrderDetails',
        component: () => import('@/views/purchaseManager/PurchaseOrder/purchaseOrderDetails'),
        meta: { title: '采购单详情', icon: 'dashboard', noCache: false },
        hidden: true
      },
      {
        path: '/purchaseOrderGoodsEdit/',
        name: 'purchaseOrderGoodsEdit',
        component: () => import('@/views/purchaseManager/PurchaseOrder/purchaseOrderGoodsEdit'),
        meta: { title: '采购单详情编辑', icon: 'dashboard', noCache: false },
        hidden: true
      },
      {
        path: '/editPurchaseOrder/:id',
        name: 'editPurchaseOrder',
        component: () => import('@/views/purchaseManager/PurchaseOrder/editPurchaseOrder'),
        meta: { title: '编辑需求单', icon: 'dashboard', noCache: false },
        hidden: true
      },
      {
        path: '/purchaseOrderDetails',
        name: 'purchaseOrderDetails',
        component: () => import('@/views/purchaseManager/PurchaseOrder/purchaseOrderDetails'),
        meta: { title: '需求单详情', icon: 'dashboard', noCache: false },
        hidden: true
      }
    ]
  },
  {
    path: '/sale',
    component: Layout,
    redirect: '/sale',
    name: '销售管理',
    meta: { title: '销售管理', icon: 'table' },
    alwaysShow: true,
    children: [
      {
        path: 'soAccountList',
        name: '选货单管理',
        component: () => import('@/views/sale/soAccountList'),
        meta: { title: '选货单管理', icon: 'table', affix: false }
      },
      {
        path: 'selectgoodsdetail',
        name: '选货单详情',
        component: () => import('@/views/sale/selectgoodsdetail'),
        meta: { title: '选货单详情', icon: 'table', affix: false },
        hidden: true
      },
      {
        path: '/packingList',
        name: 'packingList',
        component: () => import('@/views/sale/packingList/packingListManager'),
        meta: { title: '打包单管理', icon: 'table', affix: false }
      },
      {
        path: '/packdetail',
        name: 'packdetail',
        component: () => import('@/views/sale/packingList/packdetail'),
        meta: { title: '打包单详情', icon: 'table' },
        // 表示隐藏在那个导航栏
        hidden: true
      },
      {
        path: '/addPacking',
        name: 'addPacking',
        component: () => import('@/views/sale/addPacking/addPacking'),
        meta: { title: '新增打包单', icon: 'table' }
      },
      {
        path: 'addselectgoodsorder',
        name: '新增选货单',
        component: () => import('@/views/sale/addselectgoodsorder'),
        meta: { title: '新增选货单', icon: 'table', affix: false },
        hidden: true
      },
      {
        path: '/amountManager',
        name: '结算单管理',
        component: () => import('@/views/sale/amount/amountManager'),
        meta: { title: '结算单管理', icon: 'table', affix: false },
        // hidden: true
      },
      {
        path: '/amountDetail/:packingNumber',
        name: 'amountDetail/:packingNumber',
        component: () => import('@/views/sale/amount/amountDetail'),
        meta: { title: '结算单分包详情', icon: 'table', affix: false },
        hidden: true
      },
      {
        path: '/amountList/:id',
        name: 'amountList/:id',
        component: () => import('@/views/sale/amount/amountList'),
        meta: { title: '分包商品详情', icon: 'table', affix: false },
        hidden: true
      }
    ]
  },
  {
    path: '/partnership',
    component: Layout,
    redirect: '/partnership',
    name: '合作关系',
    meta: { title: '合作关系', icon: 'table' },
    alwaysShow: true,
    children: [
      // {
      //   path: '/custommanage',
      //   name: 'custommanage',
      //   component: () => import('@/views/partnership/custommanage'),
      //   meta: {title: '选货单管理', icon: 'table', affix: false}
      // },
      {
        path: '/focusbusiness',
        name: 'focusbusiness',
        component: () => import('@/views/partnership/focusbusiness'),
        meta: { title: '关注友商', icon: 'table', affix: false }
      },
      {
        path: '/focusme',
        name: 'focusme',
        component: () => import('@/views/partnership/focusme'),
        meta: { title: '客户管理', icon: 'table' }
      },
      {
        path: '/mefocus',
        name: 'mefocus',
        component: () => import('@/views/partnership/mefocus'),
        meta: { title: '业务员管理', icon: 'table' }
      }
      // {
      //   path: '/salesermanage',
      //   name: 'salesermanage',
      //   component: () => import('@/views/partnership/salesermanage'),
      //   meta: { title: '新增打包单', icon: 'table' }
      // },
      // {
      //   path: '/suppliermanage',
      //   name: 'salesermsuppliermanageanage',
      //   component: () => import('@/views/partnership/suppliermanage'),
      //   meta: { title: '新增打包单', icon: 'table' }
      // },
    ],
  },
  {
    path: '/',
    component: Layout,
    redirect: '/partnership',
    name: '商品管理',
    meta: { title: '商品管理', icon: 'table' },
    alwaysShow: true,
    children: [
      {
        path: '/focusbusiness',
        name: 'focusbusiness',
        component: () => import('@/views/partnership/focusbusiness'),
        meta: { title: '产品管理', icon: 'table', affix: false }
      },
      {
        path: '/focusme',
        name: 'focusme',
        component: () => import('@/views/partnership/focusme'),
        meta: { title: '产品关注', icon: 'table' }
      },
      {
        path: '/mefocus',
        name: 'mefocus',
        component: () => import('@/views/partnership/mefocus'),
        meta: { title: '采购定价', icon: 'table' }
      },
      {
        path: '/mefocus',
        name: 'mefocus',
        component: () => import('@/views/partnership/mefocus'),
        meta: { title: '销售定价', icon: 'table' }
      }
    ],
  },

  {
    path: '*', redirect: '/404', hidden: true
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
